<%@ taglib prefix="page" uri="http://com.qipay/pagelib" %>
<%@ page language="java" import="com.qipay.admin.tags.PageModel" contentType="text/html;charset=utf-8" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.util.List" %>
<%@ page import="com.qipay.baas.model.User" %>
<%@ page import="com.qipay.admin.utils.SiteHelper" %>
<%@ page import="com.qipay.user.entity.UserLevel" %>
<!doctype html>
<html>
<head>
    <jsp:include page="head.jsp"></jsp:include>
    <link rel="stylesheet" href="<%= request.getAttribute("StaticHost") %>/css/dataTables.bootstrap.min.css">
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <jsp:include page="nav.jsp"></jsp:include>
    <jsp:include page="left.jsp"></jsp:include>
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-xs-12">
                    <div class="box">
                        <div class="box-header">
                            <h3 class="box-title">后台用户列表</h3>
                        </div>
                        <div class="col-xs-10">
                            <form class="form-inline">
                                <a class="btn btn-success"
                                   href="${pageContext.request.contextPath}/sys/user/add">添加管理操作员</a>

                            </form>
                        </div>
                        <br>
                        <hr>
                        <!-- /.box-header -->
                        <div class="box-body">
                            <table id="example2" class="table table-bordered table-hover">
                                <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>账号</th>
                                    <th>级别</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>

                                <% List<User> articles = (List<User>) request.getAttribute("userList");
                                    PageModel pager = (PageModel) request.getAttribute("page");
                                    String query = pageContext.getRequest().getServletContext().getContextPath() + "/sys/user" + pager.getUrl();
                                    if (articles != null && articles.size() > 0) {
                                        Iterator<User> iter = articles.iterator();
                                        User user = null;
                                        UserLevel userLevel = UserLevel.CP;
                                        while (iter.hasNext()) {
                                            user = iter.next();
                                            userLevel = SiteHelper.getUserLevelByLevel(user.getLevel());

                                %>

                                <tr id="user_<%=user.getId()%>">
                                    <td><%=user.getId()%>
                                    </td>
                                    <td>
                                        <% if(user.getLevel()!=1000){%>
                                        <a href="${pageContext.request.contextPath}/sys/user/<%= user.getName()%>"><%=user.getName()%></a>
                                        <%}else{%><%= user.getName()%><%}%>
                                    </td>
                                    <td>
                                        <%= SiteHelper.getUserLevelStrByLevel(user.getLevel())%>
                                    </td>
                                    <td>
                                        <a class="button back-gray btn-xs"
                                           href="${pageContext.request.contextPath}/sys/log?uid=<%= user.getId()%>">查看日志</a>
                                    </td>
                                </tr>
                                <%
                                    }
                                } else {
                                %>
                                <tr>
                                    <td colspan="4">no data.</td>
                                </tr>
                                <% }%>
                                </tbody>
                            </table>
                            <div class="col-sm-10">

                                <div class="dataTables_paginate paging_simple_numbers" id="example1_paginate">
                                    <page:page totalSum="<%= pager.getTotal()%>"
                                               url="<%= query%>"
                                               pageNo="<%= pager.getPage()%>"
                                               pageSize="<%= pager.getPageSize()%>"></page:page>
                                </div>
                            </div>
                        </div>
                        <!-- /.box-body -->
                    </div>
                    <!-- /.box -->
                </div>
                <!-- /.col -->
            </div>
            <!-- /.row -->
        </section>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->
    <jsp:include page="foot.jsp"></jsp:include>
</div>
<script src="<%= request.getAttribute("StaticHost") %>/js/jquery.dataTables.min.js"></script>
<script src="<%= request.getAttribute("StaticHost") %>/js/dataTables.bootstrap.min.js"></script>
<script src="<%= request.getAttribute("StaticHost") %>/js/jquery.slimscroll.min.js"></script>
<script src="<%= request.getAttribute("StaticHost") %>/js/fastclick.js"></script>
<script src="<%= request.getAttribute("StaticHost") %>/js/adminlte.min.js"></script>
<script>
    $(function () {
        $('#example2').DataTable({
            'paging': false,
            'lengthChange': false,
            'searching': false,
            'ordering': true,
            'info': true,
            'autoWidth': false
        })
    })
</script>
</body>
</html>

